package com.exercises;


import com.alibaba.fastjson.JSONObject;


class Exercise1720 {
    public static void main(String[] args) {
        System.out.println(JSONObject.toJSONString(decode(new int[]{6, 2, 7, 3}, 4)));
    }

    public static int[] decode(int[] encoded, int first) {
        int length = encoded.length;
        int[] result = new int[length + 1];
        result[0] = first;
        for (int i = 1; i < length + 1; i++) {
            result[i] = encoded[i - 1] ^ result[i - 1];
        }

        return result;
    }

}

